package com.xtc.netty.io.nio.buffer;

import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

public class MappedBuffer {
    public static final int start = 0;
    public static final int size = 26;

    public static void main(String[] args) {
        try {
            String filePath = "C:\\Users\\Administrator\\Desktop\\百度网盘会员\\bufferDemo.txt";
            RandomAccessFile file = new RandomAccessFile(filePath, "rw");
            FileChannel channel = file.getChannel();

            MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, start, size);

            map.put(0, (byte)97);
            map.put(25, (byte)122);

            file.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
